#include <bits/stdc++.h>
// 2025/01/24
// tag: 
// Author: Zhang Muen
using namespace std;

signed main()
{
    string a, b;
    cin >> a >> b;
    int64_t ans = 1;
    for (int i = 0; i < a.size() - 1; i++)
        for (int j = 0; j < a.size() - 1; j++)
            if (a[i] == b[j + 1] && a[i + 1] == b[j])
                ans *= 2;
    cout << ans;
    return 0;
}